package com.dg.core.pojo;

import org.apache.ibatis.type.Alias;

@Alias("page")
public class Page
{
	private int pageSize=10;	//每页大小
	private int pageIndex;		//当前页数
	private int totalPage;		//总页数
	private int totalResult;	//总记录数
	private int currentResult;	//当前页
	private ParamsData paramsData = new ParamsData();
	private boolean isPaging = false;
	
	public boolean getIsPaging(){
	  return this.isPaging;
	}
	
	public void setIsPaging(boolean isPaging){
	  this.isPaging = isPaging;
	}
	
	public Page(){
		/*try{
			if (PageSize.size.intValue() > 0) {
				this.pageSize = PageSize.size.intValue();
			} else {
				this.pageSize = 15;
			}
		}
		catch (Exception e){
			this.pageSize = 15;
		}*/
	}
	
	public int getTotalPage(){
		if (this.totalResult % this.pageSize == 0) {
			this.totalPage = (this.totalResult / this.pageSize);
		} else {
			this.totalPage = (this.totalResult / this.pageSize + 1);
		}
		return this.totalPage;
	}
	
	public void setTotalPage(int totalPage){
		this.totalPage = totalPage;
	}
	
	public int getTotalResult(){
		return this.totalResult;
	}
	
	public void setTotalResult(int totalResult){
		this.totalResult = totalResult;
	}
	
	public ParamsData getParamsData(){
		return this.paramsData;
	}
	
	public void setParamsData(ParamsData paramsData){
		this.paramsData = paramsData;
	}
	
	public int getPageIndex(){
		if (this.pageIndex <= 0) {
			this.pageIndex = 1;
		}
		if (this.pageIndex > getTotalPage()) {
			this.pageIndex = getTotalPage();
		}
		return this.pageIndex;
	}
	
	public void setPageIndex(int pageIndex){
		this.pageIndex = pageIndex;
	}
	
	public int getPageSize(){
		return this.pageSize;
	}
	
	public void setPageSize(int pageSize){
		this.pageSize = pageSize;
	}
	
	public int getCurrentResult(){
		this.currentResult = ((getPageIndex() - 1) * getPageSize());
		if (this.currentResult < 0) {
			this.currentResult = 0;
		}
		return this.currentResult;
	}
	
	public void setCurrentResult(int currentResult){
		this.currentResult = currentResult;
	}
	
}

